#include "event_filter.h"
#include <QDialog>
#include <QKeyEvent>

EventFilter::EventFilter(QObject *parent)
    : QObject(parent)
{

}

bool EventFilter::eventFilter(QObject *obj, QEvent *event)
{
    QDialog *pDialog = qobject_cast<QDialog *>(obj);
    if (pDialog != NULL)
    {
        switch (event->type())
        {
            case QEvent::KeyPress:
            {
                QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(event);
                if (pKeyEvent->key() == Qt::Key_Escape)
                {
                    return true;
                }
            }
        }
    }
    return QObject::eventFilter(obj, event);
}

EventFilter::~EventFilter()
{

}
